<?php
/*
 * @Description    : 
 * @Author         : QianLong
 * @Date           : 2023-04-24 10:44:35
 * @LastEditors    : QianLong
 * @Site           : http://www.21ds.cn
 * @LastEditTime   : 2024-01-16 16:56:55
 */

declare(strict_types=1);

namespace App\Amqp\Consumer;

use App\Service\EnterpriseWeChat;
use Hyperf\Amqp\Result;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use PhpAmqpLib\Message\AMQPMessage;


#[Consumer(exchange: 'idp.push', routingKey: 'idp.push', queue: 'idp.push', name: "PushConsumer", nums: 1)]
class PushConsumer extends ConsumerMessage
{
    public function consumeMessage($data, AMQPMessage $message): string
    {
        $enterprise = new EnterpriseWeChat();
        $plat = 'apiError';
        $cropId = 'ww7f238368529c004a';
        $secret = 'cuTGK5S8o4pb23mI8FnIk_CDGXEd63rd7hnJx9uNsVA';
        $extData['agentid'] = 1000007;
        $extData['touser'] = 'GuoQiang';
        $extData['content'] = (is_array($data)) ? json_encode($data, JSON_UNESCAPED_UNICODE) : $data;
        $extData['content'] = $extData['content'] . 'idp.push_log2';
        $enterprise->sendTextMsg($plat, $cropId, $secret, $extData);
        unset($extData, $enterprise, $data, $plat, $cropId, $secret);
        return Result::ACK;
    }
}
